package pl.druminski.robinhood.updater;

import java.io.IOException;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
import pl.druminski.robinhood.updater.controller.Engine;
import pl.druminski.robinhood.updater.model.Data;
import pl.druminski.robinhood.updater.view.Gui;

/**
 *
 * @author Łukasz Drumiński
 */
public class Main
{

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args)
    {
        Data data = new Data();

        //tworzenie loga
        Logger logger = Logger.getLogger(data.getLogName());
        FileHandler fh;
        try
        {
            fh = new FileHandler("RobinHood.log", true);
            logger.addHandler(fh);
            logger.setLevel(Level.ALL);
            SimpleFormatter formatter = new SimpleFormatter();
            fh.setFormatter(formatter);

        } catch (IOException ex)
        {
            ex.printStackTrace();
        } catch (SecurityException ex)
        {
            ex.printStackTrace();
        }
        logger.log(Level.INFO,"Uruchamienie Updatera.");

        Gui gui = new Gui(data);

        Engine engine = new Engine(data, gui);
        Thread threadEngine = new Thread(engine);
        threadEngine.start();
    }

}
